<?php

namespace Drupal\shusy_store_order\MetadataController;

use Drupal\shusy_store_order\ViewsController\Traits\ShusyStoreOrderStatusTrait;
use EntityDefaultMetadataController;

class ShusyStoreOrderMetadataController extends EntityDefaultMetadataController {

  use ShusyStoreOrderStatusTrait;

  public function entityPropertyInfo() {
    $info = parent::entityPropertyInfo();
    $properties = &$info[$this->type]['properties'];
    $properties['user'] = [
      'label' => t('所有人'),
      'type' => 'user',
      'schema field' => 'uid',
      'description' => t('所有人.'),
    ];
    $properties['op_user'] = [
      'label' => t('操作人'),
      'type' => 'user',
      'schema field' => 'op_uid',
      'description' => t('操作人.'),
    ];

    $properties['created'] = [
      'label' => t('记录时间'),
      'type' => 'date',
      'schema field' => 'created',
      'description' => t('记录时间.'),
    ];
    $properties['changed'] = [
      'label' => t('变化时间'),
      'type' => 'date',
      'schema field' => 'changed',
      'description' => t('变化时间.'),
    ];

    $properties['lines'] = [
      'label' => t('包含项'),
      'type' => 'list<shusy_store_order_line>',
      'getter callback' => 'entity_property_getter_method',
      'description' => t('包含项.'),
    ];
    $properties['store'] = [
      'label' => t('店铺'),
      'type' => 'shusy_store',
      'schema field' => 'store_id',
      'description' => t('店铺.'),
    ];

    $properties['status'] = [
      'label' => t('状态'),
      'description' => t('状态.'),
      'type' => 'integer',
      'options list' => [$this, 'getStatusOptions'],
      'required' => TRUE,
      'schema field' => 'status',
      'setter callback' => 'entity_property_verbatim_set',
    ];

    return $info;
  }
}
